package com.jdcy.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

//@Configuration 在容器中配置Swagger
//@EnableSwagger2 启动Swagger

@Configuration
@EnableSwagger2
public class SwaggerConfig {

	// Swagger 容器初始化配置
	@Bean
	public Docket newsApi() {
		return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).select()
				.apis(RequestHandlerSelectors.basePackage("com.jdcy.web.controller")).paths(PathSelectors.any())
				.build();
	}

	// 文档信息描述
	private ApiInfo apiInfo() {
		return new ApiInfoBuilder().title("jdcy API文档").description("在这里你可以浏览项目所有接口，并提供相关测试工具")
				.termsOfServiceUrl("http://www-03.ibm.com/software/sla/sladb.nsf/sla/bm?Open").contact("test")
				.license("China Red Star Licence Version 1.0").licenseUrl("#").version("1.0").build();
	}

}
